import { post, get } from "@/common/http";
import {
  IGroupCountRes,
  ITrackLogDateRange,
  IUploadFaceInfo,
} from "@/types/common";

/**
 *
 * @param data FormData
 * @returns 本地文件上传
 */
export const uploadLocal = (data: FormData) =>
  post<string>("/api/v1/base/uploadLocal", data);

/**
 *
 * @param data FormData
 * @returns oss文件上传
 */
export const uploadOSS = (data: FormData) =>
  post<IUploadFaceInfo>("/api/v1/base/uploadOSS", data);

/**
 *
 * @returns 获取验证码
 */
export const captcha = () => get<string>("/api/v1/base/captcha");

/**
 *
 * @param moduleName
 * @returns 日志记录
 */
export const trackLogSave = (moduleName: string) =>
  post<boolean>("/api/v1/trackLog", { moduleName });

/**
 *
 * @param moduleName
 * @returns 日志记录 - 获取分组数据
 */
export const trackLogGroupCount = () =>
  get<IGroupCountRes[]>("/api/v1/trackLog/groupCount");

/**
 *
 * @param moduleName
 * @returns 日志记录 - 获数据趋势 - 时间范围
 */
export const trackLogDateRange = (range: number) =>
  get<ITrackLogDateRange>("/api/v1/trackLog/dateRange", { params: { range } });
